Project Approach :

Required df Creation

we cannot replace null value of anything like mean/rolling average in NaN Values of Time series data. that would be inappropriate data handling, hence we will drop the NaN Rows Right away
We assume that Dow Jones index is independent variable for predicting the India's BankNifty Index

Historically it is observed that Dow and HDFC Bank is having more Importance, and we will test the Correlation for the same

so,

Test of Stationarity

Dickey-Fuller test :

here we calculate how strongly a time series is defined by a trend. and given by below hypothesis tests

Null Hypothesis (H0): If failed to be rejected, it suggests the time series has a unit root, meaning it is non-stationary. It has some time dependent structure.

Alternate Hypothesis (H1): The null hypothesis is rejected; it suggests the time series does not have a unit root, meaning it is stationary. It does not have time-dependent structure.

We interpret this result using the p-value from the test. A p-value below a threshold (such as 5% or 1%) suggests we reject the null hypothesis (stationary), otherwise a p-value above the threshold suggests we fail to reject the null hypothesis (non-stationary).

BNF Close Stationarity Test

Test_stat > Critical Levels : Fail to reject Null Hypothesis, hence the Time Series is not stationary
Here, P Value is greater than 0.05, Hence Null Hypothesis Fails to reject, indicating that the Time Series is not Stationary
Before we proceed further, we need to make the Time Series Stationary, Below are the Methods that can be used to make the Time series Stationary
Order Differencing
     Yt = (Yt) - (Yt-1)

BNF Open Stationarity Test

Here, after differencing P_val < 0.05, hence Reject to Null Hypothesis, indicating the Time Series is Stationary

DJI Close Stationarity Test

Here, after first order differencing, Pval < 0.05, hence Reject to Null Hypothesis, indicating the Time Series is Stationary

1. Simple Moving Average

A simple moving average (SMA) calculates the average of a selected range of prices, usually closing prices, by the number of periods in that range.

Conclusion : Here we can see SMA_50 is having lower rmse than than of SMA_200

SMA 200 and SMA 50 are widely used SMA in Strategy called as Cross-over Stregies ( Golden Cross-over and Death Crossover)

2. Weighted Moving Average :

Exponential moving averages (EMAs) are also weighted toward the most recent prices, but the rate of decrease between one price and its preceding price is not consistent. The difference in the decrease is exponential.

Observations : we can see, Exponential Weighted Moving Average is having less rmse and mape since the EWMA model gives more weightage to the recent values

From above chart we can see that the EWMA 50 is leading and SMA 50 is lagging so we would be getting early indications from EWMA 50

3. NaiveForecaster

Naive Forecasted gives the last value of the train data as prediction value

image.png

Simple Naive Forecaster is the Benchmark model, as we can see there is significant jump in error handling when we are predicting the price with Naive forecaster

Smoothning methods

Single (Simple) Exponential Smoothning

Single Exponential Smoothing, SES for short, also called Simple Exponential Smoothing, is a time series forecasting method for univariate data without a trend or seasonality. It requires a single parameter, called alpha also called the smoothing factor or smoothing coefficient.
In Weighted Moving Average, you can give more weight to recent events, but you are limited to the last m observations. Exponential Smoothing improves on Weighted Moving Average by taking all previous observations into account, while still favoring the most recent observations.

image.png

image.png

image.png

A small α is suitable to be used for stable time series data while a large α is to deal with a series that change rapidly as BNF is a very Volatile Index, we will be using suppled alpha as 0.78

Observation : Here we can see that though we have used the Smoothning factor Alpha, there is no consideration of trend and Seasonality in the model, hence model is predicting on the basis of the Previous price action

Model Evaluation :

Double exponential smoothing ( Holt's Linear Model)

image.png

Double Exponential Smoothning_Damped

Seasonality Decomposition

And WOW......Accidently we found that Market is going up as per seasonality, on Monthly and 2 Monthly Basis

So, it looks like Seasonality is the Important Component for the BankNifty, that we can use in the further models But from Seasonality itself it is showing the uptrend

Tripple Exponential Smoothing

We use TES when there is seasonality in dataset aprt from level and trend. Datasets which show a similar set of pattern after fixed intervals of a time period have seasonality. so, Main factors of Tripple Exp Smoothing are Level (L), trend (b), seasonality (s), frequency of seasons (m) Alpha, beta and gamma are the smoothing parameters and equations are given by image-3.png

Here we will be Predicting only for 90 Days since BNF is too Volatile to predict

ACF and PACF

we will be using df_stationary_bnf_close data frame

From above we can see that both PACF and ACF are tailing off from the 1st Order
so by seeing only the PACF and ACF we can assume the ARMA model would perform good, lets see

From Above PACF we gets the P = 1 and q=1

1. Autoregression Models

image.png

MA

Autoregressive Moving Average (ARMA)

image.png

ARIMA

image.png

Here, we can see the best model to Predict the 30 Day BNF forecast is Best model: ARIMA(1,1,0)(0,0,0)[30] intercept

grangercausalitytests

Before going forward with the ARMAX and VAR, we need to check grangercausalitytests for BNF open w.r.t Previous day DJI close price

Here, Significant P value suggest that at lag 1 BNF Open is caused due to the Closing Price of DJI

ARMAX Model

image.png

Looking at AIC and BIC Criteria, we found that the ARMAX Model is predicting good BNF Open prices, with exog factor as DJI close

image.png

VAR Model

Volatility Forecasting (ARCH & GARCH)

This Volatility can be ued for the Hedging Purposes, as we can see currently we are in low volatile zone